<div id="top_content">
	<?php $story_ads = ads();?>
	<div id="top_emergency">
		<div id="top_emergency_info">
			<ul>
				<?php if (!empty($story_ads)) {?>
					<?php foreach($story_ads as $story_ad) {?>
					<?php echo '<li><a href="/story/show/' . $story_ad['id'] . '"><span class="orange">'. $story_ad['bonus'] . '元</span> | <span>' . $story_ad['title'] . '</span></a></li>'?>
					<?php }?>
				<?php } else {?>
					<li><a href="###"><span class="orange">3000元</span> | <span>寻找昨天走失的小孩</span></a></li>
					<li><a href="###"><span class="orange">2000元</span> | <span>再来做个测试</span></a></li>
					<li><a href="###"><span class="orange">1000元</span> | <span>这是第三个测试这是第三个测试</span></a></li>
				<?php }?>
			</ul>
		</div>
		<div class="page_controller right" style="margin-top:2px">
			<span class="pre"><a href="###" id="J_RotatePrev">&lt;</a></span>
			<span class="next"><a href="###" id="J_RotateNext">&gt;</a></span>
		</div>
	</div>
	<div id="top_user_info">
		<span>欢迎来行动！&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<?php 
			$current_user_nick = current_user('nickname');
			$current_user_id = current_user('user_id');
			if (!empty($current_user_nick)) {
				echo '<a href="'. site_url("user/show/?user_id=" . $current_user_id) .'" >' . $current_user_nick . "</a>";
				echo '<span id="message_count"></span>';
				echo '<a class="margin_left10" href="'. site_url("user/show/?user_id=" . $current_user_id) .'" >我的行动中心</a>';
				
		 ?>
		 	&nbsp;|&nbsp;&nbsp;<a href="<?php echo site_url("user/logout");?>">退出</a>
		</span>
		<?php } else {?>
		<a class="margin_right10" href="<?php echo site_url("user/register");?>">注册</a>
		<a  href="<?php echo site_url("user/login");?>">登录</a>		
		<?php }?>	
	</div>
</div>
<script src="/js/jquery.scroller.js"></script>
<script>
	$('#top_emergency_info').scroller('J_RotatePrev', 'J_RotateNext');
	
	$(document).ready(function(){
		<?php if (!empty($current_user_id)) {?>
		$.get('/user/ajax_message_count?user_id=<?php echo $current_user_id;?>', function(data) {
			  $('#message_count').html(data);
			});
		<?php }?>			
	});
	
</script>
